package com.example.aigc_education.enums;

import lombok.Getter;

@Getter
public enum PlanPriorityType {

    P0("P0", 0, "#D32F2F"),  // 材料设计红
    P1("P1", 1, "#FFA726"),  // 活力橙
    P2("P2", 2, "#4CAF50"), // 安全绿
    P3("P3", 3, "#2196F3");  // 材料设计蓝

    private final String title;    // P0/P1/P2 标识符
    private final Integer value; // 数据库存储的数值
    private final String color;  // 颜色代码

    PlanPriorityType(String code, Integer value, String color) {
        this.title = code;
        this.value = value;
        this.color = color;
    }

    // 通过数值获取枚举
    public static PlanPriorityType fromValue(Integer value) {
        for (PlanPriorityType type : PlanPriorityType.values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("No enum constant with value " + value);
    }

    // 通过P0/P1/P2标识符获取枚举
    public static PlanPriorityType fromTitle(String title) {
        for (PlanPriorityType type : PlanPriorityType.values()) {
            if (type.title.equals(title)) {
                return type;
            }
        }
        throw new IllegalArgumentException("No enum constant with code " + title);
    }
}